package com.gitee.sop.layui.adminserver.module.background.develop.manager;

import com.gitee.sop.layui.adminserver.module.background.develop.entity.SysFunctionRole;
import com.gitee.sop.layui.adminserver.module.background.develop.mapper.SysFunctionRoleMapper;
import com.gitee.sop.layui.adminserver.plugins.cache.util.CacheUtil;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: huwei
 * @date: 2020/6/4 15:18
 * @version: 1.0.0
 */
@Component
public class SysFunctionRoleManager {
    @Lazy
    @Resource
    private SysFunctionRoleMapper sysFunctionRoleMapper;

    public List<SysFunctionRole> getAllByRelationUserUuid(String userUuid, int status) {
        return CacheUtil.getOrPutIfAbsent(userUuid + ":" + status, () -> this.sysFunctionRoleMapper.selectAllByRelationUserUuid(userUuid, status), this.getClass().getName());
    }

    public void clearCache() {
        CacheUtil.clearDomain(this.getClass().getName());
    }
}
